<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="java.security.Principal" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="com.conversationboard.site.*" %>
<%@ page import="com.conversationboard.authenticator.AuthenticationCookie"%>
<%@ page import="com.conversationboard.tree.Folders"%>
<%@ page import="com.conversationboard.tree.Node"%>
<%@ page import="java.util.List"%>
<%@ page import="com.conversationboard.controller.ipaddress.IPAddress"%>

<% 

	if (!Configuration.getInstance().isSupportFileUploads()) {
		return;
	}

	Site.incrementPageHitCount();
	
    Principal principal = request.getUserPrincipal();
    String userName = null;
    
    if (principal != null) {
    	userName = principal.getName();
    }  
    
 	User user = User.get(userName);
 	
	int offset = Integer.parseInt(request.getParameter("offset"));
	int number = Integer.parseInt(request.getParameter("number"));

	List<UploadedFile> files = user.getUploadedFiles(offset, number);
	
	offset = offset + number;

	request.setAttribute("files", files);
	request.setAttribute("offset", offset);
	request.setAttribute("number", number);
	request.setAttribute("root", Configuration.getInstance().getRoot());
	request.setAttribute("more", (files.size() == number));
	
%>

<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta name="ROBOTS" content="NOINDEX"></meta>
	<title><%=Configuration.getInstance().getSiteName()%></title>
	<link rel="stylesheet"title="Conversation Board" type="text/css" href="${contextPath}/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>">
</head>

<body>

	<%= MainMenu.display(principal) %>

	<% if (SiteMessage.getMessage() != null) { %>	
		<div class='sitemessage'><%= SiteMessage.getMessage() %></div>
	<% } %>

	<% if (BatchMessage.getMessage() != null) { %>	
		<div class='batchmessage'><%= BatchMessage.getMessage() %></div>
	<% } %>
	
	<% if (user.isSiteAdmin() && (Site.getPendingRegistrations() > 0)) { %>
		<div class='batchmessage'><%= Site.getPendingRegistrations() %> pending registration(s).</div>
	<% } %>

	<c:if test="${user.yellowCarded}">
		<div class="yellowcard">You Have Been Yellow Carded By a Moderator: ${user.yellowCardReason}</div>
	</c:if>

	<c:if test="${siteshut}">
		<div class="sitemessage"><strong><span class="red">Site is currently shut. You are accessing as an administrator. Open the site in the admin menu option <a href="${contextPath}/Pages/Admin/openclose.jsp">Open/Close Site</a></span></strong></div>
	</c:if>
	
	<div class="headingblock">
		<h1>My Uploaded Files</h1>

	</div>

	<div class="mainblock">
		
		<table class="table">
	
		<tr class="header">
			<td class="cell">Original File Name</td>
			<td class="cell">URL (copy and paste this in its entirety to link to a file from within a post/thread)</td>
			<td class="cell">Uploaded</td>
		</tr>
	
		<c:forEach var="file" items="${files}">

			<tr class="row">
				<td class="cell">${file.originalFileName}</td>
				<td class="cell">${file.BBCode}</td>
				<td class="cell">${file.whenUploaded}</td>
			</tr>
		
		</c:forEach>
		
		</table>
		
		<c:if test="${more}">		
			<p><a href="${root}/Pages/view-uploaded-files.jsp?offset=${offset}&number=${number}">Next...</a></p>
		</c:if>
		
	</div>
	
	<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
	<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 

</body>
</html>
